package http_middleware

import (
	"gitee.com/zaper/patch/privilege"
	"gitee.com/zaper/patch/util"
	"gitee.com/zaper/private-logger"
	"github.com/gin-gonic/gin"
)

func PrivilegeFilter() gin.HandlerFunc {
	return func(context *gin.Context) {
		logger.Info("Begin privilege ... ")
		// 鉴权 sdk
		rt := privilege.Privilege()
		if !rt {
			logger.Error("Privilege fail")
			util.HttpContextJSON(context, string("Privilege fail"))
			return
		}
		logger.Info("Privilege success")
		context.Next()
	}
}
